package terra.network.packet.client;

import org.jboss.netty.buffer.ChannelBuffer;

import terra.network.packet.Packet;


public class ClientResolution extends Packet {

	public int w, h;
	public boolean fullscreen;
	
	public ClientResolution(int width, int height,boolean fscr) {
		w = width;
		h = height;
		fullscreen = fscr;
	}

	public ClientResolution() {
	}

	@Override
	public ChannelBuffer toBuffer() {
		ChannelBuffer buf = getNewBuffer();
		buf.writeByte(getId());
		buf.writeInt(w);
		buf.writeInt(h);
		buf.writeByte(fullscreen ? 1 :0);
		return buf;
	}

	@Override
	public Packet fromBuffer(ChannelBuffer buf) {
		w = buf.readInt();
		h = buf.readInt();
		fullscreen = buf.readByte() == 1 ? true : false;
		return this;
	}

	@Override
	public int getLength() {
		return 10;
	}

	@Override
	public boolean isDynamicLength() {
		return false;
	}

	@Override
	public byte getId() {
		return 2;
	}

	@Override
	public byte getPriority() {
		return PRIOR_NORMAL;
	}

}
